<?php

$cs=Yii::app()->clientScript;

$cs->registerCssFile(Yii::app()->baseUrl.'/js/jui/css/ui-lightness/jquery-ui-1.8.18.custom.css');
$cs->registerCssFile(Yii::app()->baseUrl.'/css/own.css');
$cs->registerCoreScript(Yii::app()->baseUrl.'/js/jquery.min.js');
$cs->registerScriptFile(Yii::app()->baseUrl.'/js/jui/js/jquery-ui.min.js');
$cs->registerScriptFile(Yii::app()->baseUrl.'/js/CustomGridButton.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/jui/js/jquery.ui.core.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/jui/js/jquery.ui.widget.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/jui/js/jquery.ui.position.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/jui/js/jquery.ui.menu.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/jui/js/jquery.ui.selectmenu.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/string.prototype.js');
//$cs->registerScriptFile(Yii::app()->baseUrl.'/assets/289ede29/templatesearch.js');

$this->breadcrumbs=array(
	'Templates'=>array('index'),
	'Search',
);

/*comment this because user only can search and buy*/
 /* $this->menu=array(
	array('label'=>'List Template', 'url'=>array('index')),
	array('label'=>'Create Template', 'url'=>array('create')),
);*/

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('template-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h2>Search Spinned Articles</h2>

<p>
How to find spinned articles
<ul>
<li>Below grid shows current spinned articles</li>
<li>Click Advance Search, you can search articles by selecting category, please remember select both categories</li>
<li>Preview can let you preview article that generated by the spinned article randomly</li>
<li>Download the spinned article and generate unique article by using our <a href='product/index'>article spinner</a></li>
</ul>
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
));?>
</div> 

<div id="dialog-modal" title="Basic modal dialog">
	
</div>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'template-grid',
	'dataProvider'=>$model->search(),
	//'filter'=>$model,
	'columns'=>array(
			array(
					name => 'templateId',
					visible => false,
					),
		
		'templateTitle',
		'templateSummary',
		//'templateCategoryId',
		//'userId',
		//'templateType',
		//'templateBody',
		//'buyTimes',
		
		//'prices',
		//'created',
		
		array(
			'class'=>'CButtonColumn',
			'template'=>'{Preview}',
			'buttons'=>array
			(
				'Preview'=>array
				(
					'label'=>'Preview Randomly Generate Article',
            		'imageUrl'=>Yii::app()->baseUrl.'/images/Preview-icon.png',
					'url'=>'$this->grid->controller->createUrl("/template/preview", array("templateId"=>$data->templateId))', //dialog-modal
            		'click'=>'function(){$("#dialog-modal").attr("src",$(this).attr("href")); previewingrid($("#dialog-modal").attr("src"));return false;}',
					
				),				
			),
		),
		array(
			'class'=>'CButtonColumn',
			'template'=>'{Download}',
			'buttons'=>array
			(				
				'Download'=>array
				(
					'label'=>'Buy The Template',
            		'imageUrl'=>Yii::app()->baseUrl.'/images/download.png',
					'url'=>'$this->grid->controller->createUrl("/template/download",array("templateId"=>$data->templateId))',	
            		//'click'=>'function(){}',
				),
			),
		),
	),
)); ?>
